package dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;

import model.Passenger;
import model.Role;

@Stateless
public class RoleDAO extends GenericDAO<Role> {
	
	public RoleDAO() {
		super(Role.class);
	}
	
	public Role findByPassenger(Passenger passenger) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("passenger", passenger);
		List<Role> role = super.findManyResults(Role.FIND_BY_PASSENGER, parameters);
		if (role != null) {
			if (role.isEmpty()) {
				return null;
			} else {
				return role.get(0);
			}
		} else {
			return null;
		}
	}

}
